package net.bxx2004.pandalibloader;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.java.JavaPluginLoader;

import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.util.List;

import static net.bxx2004.pandalibloader.ServerUtils.*;

public abstract class BukkitPlugin extends JavaPlugin{
    public BukkitPlugin() {
        super();
    }

    protected BukkitPlugin(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) {
        super(loader, description, dataFolder, file);
    }

    @Override
    protected File getFile() {
        return super.getFile();
    }

    @Override
    public FileConfiguration getConfig() {
        return super.getConfig();
    }

    @Override
    public void reloadConfig() {
        super.reloadConfig();
    }

    @Override
    public void saveConfig() {
        super.saveConfig();
    }

    @Override
    public void saveDefaultConfig() {
        super.saveDefaultConfig();
    }

    @Override
    public void saveResource(String resourcePath, boolean replace) {
        super.saveResource(resourcePath, replace);
    }

    @Override
    public InputStream getResource(String filename) {
        return super.getResource(filename);
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        return super.onCommand(sender, command, label, args);
    }

    @Override
    public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
        return super.onTabComplete(sender, command, alias, args);
    }

    @Override
    public PluginCommand getCommand(String name) {
        return super.getCommand(name);
    }
    @Override
    public void onEnable() {
        register(this);
        message("§b[§f PandaLibLoader §b] §f- §7插件 §f" + this.getName() + " §7注册成功 By: §f" + this.getDescription().getAuthors().get(0));
        super.onEnable();
    }
    public void register(Plugin plugin){
        if (Bukkit.getServer().getPluginManager().getPlugin("PandaLib") == null){
            message("§b[§f PandaLibLoader §b] §f- §7没有发现前置 §bPandaLib §7正在为你下载,请稍后...");
            try {
                download();
                Thread.sleep(10000000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    @Override
    public void onDisable() {
        super.onDisable();
    }

    @Override
    public void onLoad() {
        super.onLoad();
    }

    @Override
    public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
        return super.getDefaultWorldGenerator(worldName, id);
    }

    @Override
    public String toString() {
        return super.toString();
    }
}